<template>
    <div class="container">
        <img class="hd-img-responsive" src="https://skv4.oss-cn-hangzhou.aliyuncs.com/app/skv4/common1568880967000/%E6%8A%95%E8%AF%89%E5%BB%BA%E8%AE%AE.png"/>
        <div class="package-card bg-white hd-shadow">
            <van-list
                    :finished="finished"
                    :immediate-check="false"
                    @load="onLoad"
            >
                <div class="van-cell" @click="info(item)" v-for="(item, index) in newlist" :key="index">
                    <div class="van-cell__title">
                        <div>{{item.title}}</div>
                        <div class="van-cell__label">编号 : {{item.ext_code}}</div>
                        <div class="van-cell__label">时间 : {{item.create_on}}</div>
                    </div>
<!--                    <div class="van-cell__value">-->
<!--                        <span>编号:{{item.ext_code}}</span>-->
<!--                    </div>-->
                </div>
            </van-list>
        </div>
    </div>
</template>

<script>
import { getMyInfo2 } from '@/api/mine-bind-submit'
import { createNewPostServicefindHistoryList } from '@/api/mine'
import { Toast, Dialog } from 'vant'
export default {
  name: 'index',
  data () {
    return {
      value: '',
      pageObj: {
        pageSize: 10,
        pageIndex: 1
      },
      finished: false,
      newlist: []
    }
  },
  methods: {
    init () {
      this.pageObj.state = '-1'
      this.pageObj.cardId = '8'
      console.log(this.pageObj)
      createNewPostServicefindHistoryList(this.pageObj).then(ret => {
        if (ret.data.errcode === 0) {
          this.newlist.push.apply(this.newlist, ret.data.data.items)
          if (ret.data.data.totalPage === this.pageObj.pageNo) {
            this.finished = true
          } else {
            this.pageObj.totalPage = ret.data.data.totalPage
          }
        } else {
          Dialog.alert({
            message: ret.data.errmsg
          }).then(() => {
            // on close
          })
        }
      })
    },
    info (item) {
      console.log(item.id)
      this.$router.push({
        name: 'mine-complaint-detail',
        params: {
          xin_id: item.xin_id,
          card_id: '8'
        }
      })
    },
    onLoad () {
      this.pageObj.pageIndex = this.pageObj.pageIndex + 1
      console.log(this.pageObj.pageIndex)
      this.init()
    },
    onSearch () {
      const data = {
        company_name: this.value
      }
      console.log(data)
      ctcfuneralhome(data).then(ret => {
        this.newlist = ret.data.data.results
        // this.pageObj.totalRecord = ret.data.data.totalRecord
        if (ret.data.data.results.length === 0) {
          Toast.fail('暂无数据')
          this.value = this.value
        } else {
          this.newlist = ret.data.data.results
          this.value = this.value
        }
      })
    },
    getInfo () {
      getMyInfo2().then(ret => {
        let result = ret.data
        if (result.status === 1) {
          if ((result.result.Login === 'yes' && result.result.info.idcard === '') || (result.result.Login === 'yes' && result.result.info.idcard === null) || (result.result.Login === 'yes' && result.result.info.idcard === undefined)) {
            Dialog.alert({
              message: '尚未实名认证',
              confirmButtonText: '立即认证'
            }).then(() => {
              this.$router.push({
                path: 'bind_mobile'
              })
            })
          } else if ((result.result.Login === 'yes' && result.result.info.idcard !== '') && (result.result.Login === 'yes' && result.result.info.idcard !== null) && (result.result.Login === 'yes' && result.result.info.idcard !== undefined)) {
            this.phone = ret.data.result.info.mobile
          }
        }
      })
    }
  },
  mounted () {
    this.init()
    this.getInfo()
  }
}
</script>

<style scoped>
    .van-cell__title, .van-cell__value{
        -webkit-box-flex: inherit;
        -webkit-flex: inherit;
         flex: inherit;
    }
    .content{
        width: 100%;
        height: 100%;
        background-color: #F5F5F5;
    }
</style>
